﻿@using Newtonsoft.Json
@using Pyramid.Extentions
@using Pyramid.Models
@using Pyramid.Mvc.Html
@model CustomerHealthArchiveMaster

<div class="pageContent">
	@using (Html.BeginForm("EditHealthBaseInfo", "CustomerHealth", FormMethod.Post, new {@class = "pageForm required-validate", onsubmit = "return validateCallback(this, navTabAjaxDone);"}))
	{
		<div class="pageFormContent" layouth="96">
			@Html.HiddenFor(x => x.Id)
			@Html.HiddenFor(x => x.CustomerId)
			<p>
				@Html.LabelFor(model => model.CustomerCode)
				@Html.ReadonlyFieldFor(model => model.CustomerCode)
			</p>
			<p>
				@Html.LabelFor(model => model.CustomerFullName)
				@Html.ReadonlyFieldFor(model => model.CustomerFullName)
			</p>
			<p>
				@Html.LabelFor(model => model.Height)
				@Html.TextBoxFor(model => model.Height, new {@class = "number required"})
			</p>
			<p>
				@Html.LabelFor(model => model.Weight)
				@Html.TextBoxFor(model => model.Weight, new {@class = "number required"})
			</p>
			<p>
				@Html.LabelFor(model => model.BodilyForm)
				@Html.DropDownList("BodilyForm", Model.BodilyFormEnum.ToSelectList(), new {@class = "required"})
			</p>
			<p class="nowrap">
				@Html.LabelFor(model => model.Hypersusceptibility)
				@Html.TextAreaFor(model => model.Hypersusceptibility, new {@class = "longText longParagraph"})
			</p>
			<p class="nowrap">
				@Html.LabelFor(model => model.Disease)
				@Html.TextAreaFor(model => model.Disease, new {@class = "longText longParagraph"})
			</p>
			<p class="nowrap">
				@Html.LabelFor(model => model.Operation)
				@Html.TextAreaFor(model => model.Operation, new {@class = "longText longParagraph"})
			</p>
			<p class="nowrap">
				@Html.LabelFor(model => model.Heredopathia)
				@Html.TextAreaFor(model => model.Heredopathia, new {@class = "longText longParagraph"})
			</p>
			<p class="nowrap">
				@Html.LabelFor(model => model.HumanBodySystem)
				<div>
					@{
						var systems = (IEnumerable<HumanBodySystem>) ViewBag.HumanBodySystemOptions;
						var selectedItems = new List<int>();
						if (!string.IsNullOrWhiteSpace(Model.HumanBodySystem))
						{
							selectedItems = JsonConvert.DeserializeObject<List<int>>(Model.HumanBodySystem);
						}
						<table>
							@foreach (var sys in systems)
							{
								<tr>
									<td width="120">@sys.Name</td>
									<td>
										@foreach (var condition in sys.HealthConditions)
										{
											<label>
												<input type="checkbox" name="selectedConditions" value="@condition.Id" 
													@(Html.Raw((selectedItems.Count > 0 && selectedItems.Contains(condition.Id)) ? "checked=\"checked\"" : "")) />
												@condition.Name
											</label>
										}
									</td>
								</tr>
							}
						</table>
					}
				</div>
			</p>
			<div class="divider"></div>
			<p>
				@Html.LabelFor(model => model.CreateUserId)
				@Html.ReadonlyFieldFor(model => model.CreateUserId)
			</p>
			<p>
				@Html.LabelFor(model => model.CreateTime)
				@Html.ReadonlyDateTimeFor(model => model.CreateTime)
			</p>
			<p>
				@Html.LabelFor(model => model.EditUserId)
				@Html.ReadonlyFieldFor(model => model.EditUserId)
			</p>
			<p>
				@Html.LabelFor(model => model.EditTime)
				@Html.ReadonlyDateTimeFor(model => model.EditTime)
			</p>
		</div>
		<div class="formBar">
			<ul>
				<li>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">保存</button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	}
</div>